using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.ConnectionEngine.SampleDeploymentManager.WizardPages
{
    public partial class InstallFolderPage : WizardPageBase
    {
        private const string DEST_FOLDER = "destinationFolder";

        public InstallFolderPage()
        {
            InitializeComponent();
        }

        public override void Activate(ref Dictionary<string, object> parameters)
        {
            base.Activate(ref parameters);

            if (_parameters.ContainsKey(DEST_FOLDER)) txtFolder.Text = _parameters[DEST_FOLDER].ToString();
        }

        private void txtFolder_Leave(object sender, EventArgs e)
        {
            if (_parameters.ContainsKey(DEST_FOLDER)) _parameters.Remove(DEST_FOLDER);
            _parameters.Add(DEST_FOLDER, txtFolder.Text);
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (dlgFolderBrowser.ShowDialog(this) == DialogResult.OK)
            {
                txtFolder.Text = dlgFolderBrowser.SelectedPath;

                if (_parameters.ContainsKey(DEST_FOLDER)) _parameters.Remove(DEST_FOLDER);
                _parameters.Add(DEST_FOLDER, txtFolder.Text);
            }
        }
    }
}
